package com.wxzz.elearing.evaluation.api.app;


import com.alibaba.fastjson.JSONObject;
import com.wxzz.elearing.evaluation.entity.BusinessCategory;
import com.wxzz.elearing.evaluation.service.IBusinessCategoryService;
import com.wxzz.elearning.common.vo.ReturnVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 行业类目/组别管理 前端控制器
 * </p>
 *
 * @author
 * @since 2021-04-10
 */
@RestController
@RequestMapping("/wx-business-category")
@Api(tags = "行业类目/组别管理接口(小程序)")
public class WxBusinessCategoryController {

    @Autowired
    private IBusinessCategoryService businessCategoryService;

    @ApiOperation(value = " 行业类目列表(小程序)", notes = " 行业类目列表(小程序)", httpMethod = "POST", tags = "小程序")
    @RequestMapping(value = "wxListBusinessCategory", method = RequestMethod.POST)
    public ReturnVO<List<BusinessCategory>> wxListBusinessCategory() {
        return businessCategoryService.wxListBusinessCategory();
    }

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @ApiOperation(value = " 查询出当前用户对应的测试介绍(小程序)", notes = "查询出当前用户对应的测试介绍(小程序)", httpMethod = "POST", tags = "小程序")
    @RequestMapping(value = "selectCurUserBusinessCategory", method = RequestMethod.POST)
    public ReturnVO selectCurUserBusinessCategory(@RequestHeader String token) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return businessCategoryService.selectCurUserBusinessCategory(jsonObject.getLong("id"));
    }
}
